

import java.util.ArrayList;
import Server.Proxy;
import fit.ActionFixture;

public class CheckMember extends ActionFixture {
	
	
	Proxy func;
	String userID;
	String status;
	String firstName;
	String lastName;
	String phone;
	String email;
	String role="1";
	String password;
	
	public void connection() {
		func = new Proxy("jdbc:mysql://localhost/obl2", "root","");
		addNewUser();
	}

	public void setID(String id) {
		this.userID=id;
	}
	public void setStatus(String status) {
		this.status=status;
	}
	public void setFirstName(String firstName) {
		this.firstName=firstName;
	}
	public void setLastName(String lastName) {
		this.lastName=lastName;
	}
	public void setPhone(String phone) {
		this.phone=phone;
	}
	public void setEmail(String email) {
		this.email=email;
	}
	public void setPassword(String password) {
		this.password=password;
	}
	
	
	
	
	public void addNewUser() {
		ArrayList<String> ref = new ArrayList<String>();
		ArrayList<String> ref1 = new ArrayList<String>();
		ref.add("add_newUser");
		setID("50");
		setEmail("avi@gmail.com");
		setPassword("1234");
		ref.add(userID);
		ref.add(email);
		ref.add(password);
		ref.add(role);
		func.add_newUser(ref);
		ref1.add("add_newReaderCard");
		setFirstName("avi");
		setLastName("aviner");
		setPhone("0455555");
		setStatus("0");
		ref1.add(userID);
		ref1.add(firstName);
		ref1.add(lastName);
		ref1.add(phone);
		ref1.add(role);
		func.add_newReaderCard(ref1);	
	}
	public String UpdateReaderCard() {
		ArrayList<String> result = new ArrayList<String>();
		ArrayList<String> checkresult = new ArrayList<String>();
		ArrayList<String> checkresult2 = new ArrayList<String>();
		ArrayList<String> ref = new ArrayList<String>();
		ref.add("UpdateReaderCard");
		ref.add(userID);
		ref.add(status);
		ref.add(firstName);
		ref.add(lastName);
		ref.add(phone);
		ref.add(email);
		ref.add(password);
		func.UpdateReaderCard(ref);
		checkresult=func.getUserdetails(ref);
		checkresult2=func.getMemberdetails(ref);
		if (checkresult.get(0).equalsIgnoreCase(userID) && checkresult.get(1).equalsIgnoreCase(email)
				&& checkresult.get(2).equalsIgnoreCase(password) && checkresult.get(3).equalsIgnoreCase(role)
				&& checkresult2.get(0).equalsIgnoreCase(firstName) && checkresult2.get(1).equalsIgnoreCase(lastName)
				&& checkresult2.get(2).equalsIgnoreCase(email) && checkresult2.get(3).equalsIgnoreCase(status)
				&& checkresult2.get(4).equalsIgnoreCase(phone))
				return "true";
		else 
			return "false";

	}
	
	
	
	

}

